#include <bits/stdc++.h>
#define rg register
#define pc putchar
#define gc getchar
#define pf printf
#define space pc(' ')
#define enter pc('\n')
#define me(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define FOR(i,k,n,p) for(rg int i(k) ; i <= n ; i += p)
#define ROF(i,k,n,p) for(rg int i(k) ; i >= n ; i -= p)
using namespace std;
const int N = 2e5+5 ;
int n,q ;
int a[N],mx[N],dp[N][2] ;
inline double Time()
{
	return (double)clock()/CLOCKS_PER_SEC;
}
inline void read(int &x)
{
	x = 0 ;rg int f(0) ; rg char c(gc()) ;
	while(!isdigit(c)) f |= (c=='-'),c = gc() ;
	while(isdigit(c)) x = (x<<1)+(x<<3)+(c^48),c = gc() ;
	x = (f?-x:x) ;
}
int stk[30],tp ;
inline void print(int x){
	if(x < 0) pc('-'),x = -x ;
	do stk[++tp] = x%10,x /= 10 ; while(x) ;
	while(tp) pc(stk[tp--]^48) ;
}
int main()
{
//    freopen(".in","r",stdin) ;
//    freopen(".out","w",stdout) ;
 	read(n) ;
 	FOR(i,1,n-1,1) read(a[i]) ;
 	read(q) ;
 	while(q--)
 	{
 		read(a[n]) ; me(dp,0),me(mx,0) ;
 		dp[1][0] = a[1],dp[2][1] = a[2] ;
 		FOR(i,1,n,1) FOR(j,0,1,1)
 		{ 
 			me(mx,0) ;
 			FOR(k,1,i-1,1) mx[k] = max(mx[k-1],dp[k][j^1]) ;
 			FOR(k,i,n,1) mx[k] = mx[k-1] ;
			FOR(k,1,n,1) if(k != i)
				dp[k][j^1] = max(dp[k][j^1],mx[k-1]+a[k]) ;
		 }
		 FOR(i,0,1,1) 
		 {
		 	FOR(j,1,n,1) print(dp[j][i]),space ;
		 	enter ;
		 }
	 }
    return 0;
}


